package com.ctshk.app.season.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.AppReq;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.season.dto.AppFixedSeasonProductDTO;
import com.ctshk.rpc.season.dto.FixedSeasonDetailsDTO;
import com.ctshk.rpc.season.dto.HomePageAppDTO;
import com.ctshk.rpc.season.req.AppSearchFixedProductReq;
import com.ctshk.rpc.season.service.ISeasonFixedProductPackageService;
import com.ctshk.rpc.season.service.ISeasonFixedProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 * 套票-固定套票产App端 前端控制器
 * </p>
 *
 * @author 杨林
 * @since 2021-03-08
 */
@Slf4j
@Api(value = "APP套票-固定套票产品基本信息", tags = "APP套票-固定套票产品基本信息")
@RestController
@RequestMapping("/appSeason")
public class H5SeasonFixedProductController extends BaseController {

    @DubboReference
    private ISeasonFixedProductPackageService seasonFixedProductPackageService;
    @DubboReference
    private ISeasonFixedProductService seasonFixedProductService;

    @ApiOperation(value = "线上-固定套票-固定套票详情", notes = "线上-固定套票-固定套票详情")
    @OperationLogAnnotation(operModul = OperationLogModel.SEASONFIXEDPRODUCT, operType = OperationLogType.QUERY, operTitle = "线上-固定套票详情", operDesc = "线上-固定套票详情")
    @PostMapping("/onLineSeasonDetails")
    public Result<FixedSeasonDetailsDTO> detailsC(@RequestBody AppSearchFixedProductReq req,@ApiIgnore AppReq appReq) {
        //获取预订中心 固定套票 产品详情
        req.setChannelId(appReq.getChannelId());
        log.info("线上-固定套票-固定套票详情 接口获取到的 appReq "+ appReq.getChannelId());
        return seasonFixedProductPackageService.getAppFixedSeasonProductDetails(req, getCurrentUserAllowNotLogInUserId());
    }

    @ApiOperation(value = "线上-固定套票-更换产品", notes = "线上-固定套票-更换产品")
    @OperationLogAnnotation(operModul = OperationLogModel.SEASONFIXEDPRODUCT, operType = OperationLogType.QUERY, operTitle = "线上-更换产品", operDesc = "线上-更换产品")
    @PostMapping("/getChangeAppFixedSeasonProductDetails")
    public Result<FixedSeasonDetailsDTO> getChangeAppFixedSeasonProductDetails(@RequestBody AppSearchFixedProductReq req,@ApiIgnore AppReq appReq) {
        //获取预订中心 固定套票 产品详情
        return seasonFixedProductPackageService.getChangeAppFixedSeasonProductDetails(req, getCurrentUserAllowNotLogInUserId(),appReq.getChannelId());
    }

    @ApiOperation(value = "线上-固定套票-首页", notes = "线上-固定套票-首页")
    @OperationLogAnnotation(operModul = OperationLogModel.SEASONFIXEDPRODUCT, operType = OperationLogType.QUERY, operTitle = "线上-固定套票首页", operDesc = "线上-固定套票首页")
    @PostMapping("/onLineSeasonHomePage")
    public Result<HomePageAppDTO> onLineSeasonHomePage(@RequestBody AppSearchFixedProductReq req,@ApiIgnore AppReq appReq) {
        //获取预订中心 固定套票 产品详情
        req.setChannelId(appReq.getChannelId());
        return seasonFixedProductService.onLineSeasonHomePage(getCurrentUserAllowNotLogInUserId(), req);
    }

    @ApiOperation(value = "线上-固定套票-搜索", notes = "线上-固定套票-搜索")
    @OperationLogAnnotation(operModul = OperationLogModel.SEASONFIXEDPRODUCT, operType = OperationLogType.QUERY, operTitle = "线上-固定套票搜索", operDesc = "线上-固定套票搜索")
    @PostMapping("/onLineSeasonSearch")
    public Result<PageResponse<AppFixedSeasonProductDTO>> onLineSeasonSearch(@RequestBody AppSearchFixedProductReq req, @ApiIgnore AppReq appReq) {
        //获取预订中心 固定套票 产品详情
        req.setChannelId(appReq.getChannelId());
        log.info("线上-固定套票-搜索 接口获取到的 appReq "+ appReq.getChannelId());
        return seasonFixedProductService.onLineSeasonSearch(getCurrentUserAllowNotLogInUserId(), req);
    }


}
